﻿using NHibernate.Linq.Functions;

namespace Framework.Repositories.NHibernate
{
    /// <summary>
    /// Represents extended LINQ to HQL generator registry which contains
    /// the extender for supporting Equals method on primitive CLR types.
    /// </summary>
    /// <remarks>The HQL generator in NHibernate 3 only supports the Equals method
    /// on the <see cref="System.String"/> type, for other primitive CLR types, it
    /// is not supported. This class is for solving this issue. For more information
    /// please refer to http://www.primordialcode.com/blog/post/nhibernate-3-extending-linq-provider-fix-notsupportedexception.
    /// </remarks>
    /// <example>
    /// Remember to use the following configuration on NHibernate 3:
    /// <code>configuration.SetProperties("linqtohql.generatorsregistry", "Apworks.Repositories.NHibernate.ExtendedLinqToHqlGeneratorsRegistry, Apworks.Repositories.NHibernate");</code>
    /// or
    /// <code>configuration.LinqToHqlGeneratorsRegistry&lt;ExtendedLinqToHqlGeneratorsRegistry&gt;();</code>
    /// </example>
    public class ExtendedLinqToHqlGeneratorsRegistry : DefaultLinqToHqlGeneratorsRegistry
    {
        #region Ctor
        /// <summary>
        /// Initializes a new instance of <c>ExtendedLinqToHqlGeneratorsRegistry</c> class.
        /// </summary>
        public ExtendedLinqToHqlGeneratorsRegistry()
        {
            this.Merge(new ExtendedEqualsGenerator());
        }
        #endregion
    }
}
